//
//  PayItemModel.swift
//
//  Created by eme on 2016/12/25
//  Copyright (c) . All rights reserved.
//

import Foundation
import SwiftyJSON
import ModelProtocol

class PayItemModel: ModelProtocol {
    
    // MARK: Declaration for string constants to be used to decode and also serialize.
    internal let kPayItemPaytypeKey: String = "paytype"
    internal let kPayItemPayobjKey: String = "payobj"
    
    
    // MARK: 属性
    var paytype: String
    var payobj: PayobjModel
    
    
    // MARK: 实现ModelProtocol 协议， 解析json数据
    required  init?(json: JSON) {
        paytype = json[kPayItemPaytypeKey].stringValue
        payobj = PayobjModel(json: json[kPayItemPayobjKey])!
        
    }
    
    
    /**
     Generates description of the object in the form of a NSDictionary.
     - returns: A Key value pair containing all valid values in the object.
     */
    internal func dictionaryRepresentation() -> [String : AnyObject ] {
        
        var dictionary: [String : AnyObject ] = [ : ]
        
        dictionary.updateValue(paytype as AnyObject, forKey: kPayItemPaytypeKey)
        
        dictionary.updateValue(payobj.dictionaryRepresentation() as AnyObject, forKey: kPayItemPayobjKey)
        
        return dictionary
    }
    
    
}
